package com.example.mydesignmodule.adapter;

/**
 * @author tgw
 * @date 2021/1/21
 */
public class MediaAdapter implements MediaPlayer {
    private MediaPlayerType mediaPlayerType;

    public MediaAdapter(MediaPlayerType type) {
        if (type instanceof Mp4) {
            mediaPlayerType = new Mp4();
        } else if (type instanceof Mp3) {
            mediaPlayerType = new Mp3();
        }

    }

    @Override
    public void play(Object type) {
        if (type instanceof Mp4) {
            mediaPlayerType.playMp4();
        } else if (type instanceof Mp3) {
            mediaPlayerType.playMp3();
        }

    }
}
